package com.teyao.teyao_back.service.impl;


import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teyao.teyao_back.entity.OrderDetails;
import com.teyao.teyao_back.entity.ResponseMessage;
import com.teyao.teyao_back.mapper.OrderDetailsMapper;
import com.teyao.teyao_back.service.OrderDetailsService;
import org.springframework.stereotype.Service;

@Service
public class OrderDetailsServiceImpl extends ServiceImpl<OrderDetailsMapper, OrderDetails> implements OrderDetailsService {


    @Override
    public ResponseMessage updateFinishQuantity(OrderDetails orderDetails) {
        ResponseMessage responseMessage = new ResponseMessage();
        UpdateWrapper<OrderDetails> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("order_id", orderDetails.getOrderId()).eq("product_id", orderDetails.getProductId());
        boolean success = baseMapper.update(orderDetails, updateWrapper) > 0 ? true : false;
        responseMessage.setSuccess(success);
        return responseMessage;
    }
}
